#pragma once

#include "resource.h"

//#include "windows.h"
#include "..\DLL_FileSourceReader_Template\DLL_FileSourceReader_Template.h"
#include "..\DLL_SqlInserter_Template\DLL_SqlInserter_Template.h"

typedef struct tagControls
{
	bool bActive;
	CRITICAL_SECTION cs;
	HWND hDlg, hOk, hCancel, hProgress, hStatusText;
	HWND hProgressBars[10];
} TControls, *PControls;

typedef struct tagInputDescription
{
	// dll
	wchar_t szDllFilename[MAX_PATH];
	HMODULE hDll;
	TCreateSliceTestDescription pCreateSliceTestDescription;
	TOpenSlice pOpenSlice;
	TGetRow pGetRow;
	TCloseSlice pCloseSlice;
	// settings
	TSliceDescription slice;
	//wchar_t szDataFilename[MAX_PATH];
	//HANDLE hDataFile;
	
	// status
	bool bOk;
} TInputDescription, *PInputDescription;

typedef struct tagOutputDescription
{
	// dll
	wchar_t szDllFilename[MAX_PATH];
	HMODULE hDll;

	// settings
	TInsert insert;
	
	// status
	bool bOk;
} TOutputDescription, *POutputDescription;

typedef struct tagThreadData
{
    DWORD dwThreadId;
    HANDLE hThread;
	bool bCancelled;
	TControls c;
	TInputDescription input;
	TOutputDescription output;
} TThreadData, *PThreadData;

PThreadData StartElThread(wchar_t *szCommandline);
void StopElThread(PThreadData *ppData);

#ifndef malloc
#define malloc(sz) HeapAlloc(GetProcessHeap(), 0, sz)
#endif //malloc

#ifndef free
#define free(p) HeapFree(GetProcessHeap(), 0, p)
#endif //free

#ifndef MAX_PATH
#define MAX_PATH 4096
#endif // MAX_PATH

#ifndef MAX_WAIT_LENGTH
#define MAX_WAIT_LENGTH 50
#endif // MAX_WAIT_LENGTH